/**
 * 项目名称: Topic_341.cpp
 * 项目路径: study/DataStructure/LeetCode/树/中等
 * 编辑时间: 2024年08月28日08时13分52秒
 * 用   户: 轻尘
 */

#include <bits/stdc++.h>

using namespace std;


class NestedInteger {
public:
    // Return true if this NestedInteger holds a single integer, rather than a nested list.
    bool isInteger() const;

    // Return the single integer that this NestedInteger holds, if it holds a single integer
    // The result is undefined if this NestedInteger holds a nested list
    int getInteger() const;

    // Return the nested list that this NestedInteger holds, if it holds a nested list
    // The result is undefined if this NestedInteger holds a single integer
    const vector<NestedInteger> &getList() const;
};


class NestedIterator {
public:
    vector<int>vn;
    int cnt =0 ;
    void part(vector<NestedInteger> nestedList){
        for(auto x:nestedList){
            if(x.isInteger())vn.push_back(x.getInteger());
            else{
                part(x.getList());
            }
        }
    }
    NestedIterator(vector<NestedInteger> &nestedList) {
        part(nestedList);
    }

    int next() {
        return vn[cnt++];
    }

    bool hasNext() {
        return cnt != vn.size();
    }
};
